package com.baolai.mapper;

import com.baolai.dto.Device;
import com.baolai.entity.GoodsDevice;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface GoodsDeviceMapper extends BaseMapper<GoodsDevice> {

    @Select("select 设备编号 as device_id,设备名称 as device_name from 设备信息表 where 设备编号 = ${deviceId}")
    List<Device> getDevice(String deviceId);

    @Select("select top ${size} 设备编号 as device_id,设备名称 as device_name " +
            "from (select row_number() over(order by 设备编号 asc) as row_number,* from 设备信息表) temp_row " +
            "where row_number>${current} " +
            "and 设备名称 like '${key}%' or 设备编号 like '${key}%'")
    List<Device> listDeviceByName(String key, Integer current, Integer size);

    @Select("select top ${size} 设备编号 as device_id,设备名称 as device_name " +
            "from (select row_number() over(order by 设备编号 asc) as row_number,* from 设备信息表) " +
            "temp_row where row_number>${current}")
    List<Device> listDevice(Integer current,Integer size);

    @Select("select count(*) from 设备信息表")
    Integer countDevice();
}
